package personal.vivian.interf;

import personal.vivian.builder.DataTemplate;
import personal.vivian.builder.DataTransformer;
import personal.vivian.logic.DataContext;

public class TransformOpertion<T> {
    private DataTransformer dataTransform;
    DataContext dataContext;
    private T item;

    public TransformOpertion(DataTransformer dataTransform, DataContext dataContext, T item) {
        this.dataTransform = dataTransform;
        this.dataContext = dataContext;
        this.item = item;
    }
    //校验
    public TransformOpertion<T> validte(){
        DataTemplate dataTemplate=dataTransform.getDataManager().getDataTemplate(item.getClass());
        dataTransform.getDataManager().valdtor(dataContext,dataTemplate,item);
        return this;
    }
    //转换
    public TransformOpertion<T> convert(){
        return this;
    }
    //保存隐藏字段给调用端
    public TransformOpertion<T> save(){
        dataTransform.getDataManager().saveModel(dataContext,item);
        return this;
    }
    //从调用端还原隐藏字段，按照editmode
    public TransformOpertion<T> restore(){
        dataTransform.getDataManager().resoreModel(dataContext,item);
        return this;
    }
}
